package com.yh.modules.data;

import com.yh.modules.data.entity.MachineCountResult;
import org.springframework.stereotype.Service;

import java.util.*;

/**
 * @Author: skh
 * @Date: 2020/3/5 15:44
 * @Description:
 */
@Service
public class MachineCountServiceImpl {



    public static void main(String[] args) {
        List<MachineCountResult> testData = getTestData();
        Map<String, Integer> map = getTime();
        for (MachineCountResult data : testData) {
            if (map.containsKey(data.getTime())) {
                map.put(data.getTime(), data.getCount());
            }
        }

        for (String key : map.keySet()) {
            System.out.println(key + "," + map.get(key));
        }
    }

    private static Map<String, Integer> getTime() {
        LinkedHashMap<String, Integer> map = new LinkedHashMap<>();

        boolean begin = true;
        for (int i = 0; i <= 23; i++) {
            for (int j = 0; j < 2; j++) {
                StringBuilder sb = new StringBuilder();
                if (String.valueOf(i).length() == 1) {
                    sb.append("0");
                }
                sb.append(i);
                sb.append(":");
                if (begin) {
                    sb.append("00");
                    begin = false;
                } else {
                    sb.append("30");
                    begin = true;
                }
                map.put(sb.toString(), 0);
            }
        }
        return map;
    }

    private static List<MachineCountResult> getTestData() {
        List<MachineCountResult> machineCountResultList = new ArrayList<>();
        MachineCountResult machineCountResult1 = new MachineCountResult("00:00", 1000);
        MachineCountResult machineCountResult2 = new MachineCountResult("00:30", 2000);
        MachineCountResult machineCountResult3 = new MachineCountResult("01:00", 3000);
        MachineCountResult machineCountResult4 = new MachineCountResult("02:00", 4000);
        MachineCountResult machineCountResult5 = new MachineCountResult("06:00", 5000);
        MachineCountResult machineCountResult6 = new MachineCountResult("07:30", 6000);
        MachineCountResult machineCountResult7 = new MachineCountResult("23:30", 7000);
        machineCountResultList.add(machineCountResult1);
        machineCountResultList.add(machineCountResult2);
        machineCountResultList.add(machineCountResult3);
        machineCountResultList.add(machineCountResult4);
        machineCountResultList.add(machineCountResult5);
        machineCountResultList.add(machineCountResult6);
        machineCountResultList.add(machineCountResult7);
        return machineCountResultList;
    }
}
